# Maintainer: Bruno Pagani <archange@archlinux.org>

_pkg=dask
pkgname=python-${_pkg}
pkgver=2023.4.0
pkgrel=1
pkgdesc="Parallel computing with task scheduling"
arch=(any)
url="https://dask.org"
license=(BSD)
depends=(
    mpdecimal
    python
    python-click
    python-cloudpickle
    python-fsspec
    python-importlib-metadata
    python-packaging
    python-partd
    python-pyyaml
    python-toolz
)
makedepends=(
    python-build
    python-installer
    python-setuptools
    python-versioneer
    python-wheel
)
optdepends=(
#    'python-bokeh: visualizing dask diagnostics'
#    'python-cityhash: faster hashing of arrays'
    'python-distributed: distributed computing'
#    'python-fastparquet: storing and reading data from parquet files'
#    'python-gcsfs: file-system interface to Google Cloud Storage'
#    'python-jinja: diagnostics'
#    'python-murmurhash: faster hashing of arrays'
    'python-numpy: arrays and dataframes support'
    'python-pandas: dataframes support'
    'python-psutil: more accurate CPU count'
    'python-pyarrow: Apache Arrow, for parquet support'
#    'python-s3fs: Amazon S3 support'
    'python-sqlalchemy: writing and reading from SQL databases'
    'python-xxhash: faster hashing of arrays'
)
checkdepends=(
    ipython
    python-pytest
    python-pytest-rerunfailures
    python-aiohttp
#    python-bokeh
    python-boto3
    python-botocore
    python-cytoolz
#    python-cityhash
    python-distributed
#    python-fastparquet
#    python-gcsfs
    python-graphviz
    python-h5py
    python-httpretty
    python-jinja
    python-jsonschema
    python-lz4
    python-matplotlib
    python-moto
#    python-murmurhash
#    python-numba
    python-numexpr
    python-numpy
    python-pandas
    python-psutil
    python-pyarrow
    python-pytables
    python-requests
#    python-s3fs
    python-scikit-learn
    python-scipy
    python-snappy
#    python-sparse
    python-sqlalchemy
    python-xarray
    python-xxhash
)
#source=(https://files.pythonhosted.org/packages/source/${_pkg::1}/${_pkg}/${_pkg}-${pkgver}.tar.gz)
source=(https://github.com/dask/dask/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('f3d4d4ab004f617f7f8f0dddac55a87c6ebae19fccdf2b68a400870bdbfbd4d3')

build() {
  cd ${_pkg}-${pkgver}
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  local pytest_options=(
    -vv
    --ignore test_dir/$site_packages/$_pkg/tests/test_distributed.py
  )

  cd ${_pkg}-${pkgver}
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="$PWD/test_dir/$site_packages:$PYTHONPATH"
  pytest "${pytest_options[@]}" "$PWD/test_dir/$site_packages/$_pkg/"
}

package() {
  cd ${_pkg}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE.txt -t "${pkgdir}"/usr/share/licenses/${pkgname}/
}
